🔁 Top 30 Python List Methods You Should Know
🔁 Top 30 Python List Methods You Should Know 🧠📋
1. append() – Add element to the end
2. extend() – Add multiple elements from another list
3. insert() – Insert element at specific index
4. remove() – Remove first occurrence of a value
5. pop() – Remove element at index (default last)
6. index() – Find index of first occurrence
7. count() – Count occurrences of value
8. sort() – Sort list in ascending order (in-place)
9. reverse() – Reverse list (in-place)
10. copy() – Create a shallow copy
11. clear() – Remove all elements
12. len() – Get length of list
13. sum() – Sum numeric elements
14. min() – Minimum value
15. max() – Maximum value
16. any() – Check if any element is True
17. all() – Check if all elements are True
18. reversed() – Return iterator in reverse
19. sorted() – Return new sorted list
20. enumerate() – Get index and value in loop
21. zip() – Combine multiple lists
22. filter() – Filter elements by condition
23. map() – Apply function to each element
24. slice – Access part of list
25. copy.deepcopy() – Deep copy nested lists
26. isinstance() – Check if object is a list
27. sum() with generator – Sum of filtered values
28. del – Delete element or slice
29. * operator – Repeat list
30. list() – Convert iterable to list
Comments
Post a Comment